<div class="subhead ">
  <div class="container mx-auto">
    <h5>~/admin/sources</h5>
    <div class="log-settings">
      <%= render LogflareWeb.AdminSharedView, "nav_links.html", conn: @conn %>
    </div>
  </div>
</div>
<div class="content dashboard container mx-auto">
  <div class="dropdown">
    <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown"
      aria-haspopup="true" aria-expanded="false">
      Sort by: <%= @conn.params["sort_by"] %>
    </button>
    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
      <%= for option <- @sort_options do %>
      <%= link option, to: Routes.admin_path(@conn, :sources, sort_by: option), class: "dropdown-item" %>
      <% end %>
    </div>
  </div>
  <ul class="list-group">
    <%= for source <- @sources do %>
    <li class="list-group-item">
      <div>
        <div class="float-right">
        </div>
        <div class="source-link word-break-all">
          <%= link source.name, to: Routes.source_path(@conn, :show, source.id) %>
          <span id="<%= source.token %>">
            <small class="my-badge my-badge-info">
              <%= source.metrics.inserts_string %>
            </small>
          </span>
        </div>
      </div>
      <%= render(LogflareWeb.SharedView, "dashboard_source_metadata.html", conn: @conn, source: source) %>
    </li>
    <% end %>
  </ul>
  <%= if @sources.total_pages > 1 do %>
  <%= pagination_links @sources, sort_by: @conn.params["sort_by"] %>
  <% end %>
</div>
<div id="__phx-assigns__" data-source-tokens="<%= Jason.encode!(Enum.map(@sources, &Atom.to_string(&1.token))) %>">
</div>
<script>
  document.addEventListener("DOMContentLoaded", async () => {
    await Dashboard.main()
  })

</script>
